package com.dropesoft.biz;

import com.dropesoft.entities.DashboardEntry;

import dropesoft.com.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class DashboardAdapter extends ArrayAdapter<DashboardEntry> {
  private Context context;
  private DashboardEntry[] entries;

  public DashboardAdapter(Context context, int textViewResourceId,
      DashboardEntry[] objects) {
    super(context, textViewResourceId, objects);

    this.context = context;
    entries = objects;
  }

  public View getView(int position, View convertView, ViewGroup parent) {
    TextView titleTextView;
    if (convertView == null) {
      LayoutInflater inflater = LayoutInflater.from(context);
      View item = inflater.inflate(R.layout.dashboard_entry, parent,
          false);
      titleTextView = (TextView) item.findViewById(R.id.titleTextView);
      titleTextView.setText(entries[position].getTitle());
      titleTextView.setCompoundDrawablesWithIntrinsicBounds(0,
          entries[position].getIcon(), 0, 0);

      convertView = titleTextView;
    } else {
      titleTextView = (TextView) convertView;
    }
    return titleTextView;
  }

  public int getCount() {
    return entries.length;
  }

  public long getItemId(int position) {
    return 0;
  }
}